import { PaginationProps } from "ant-design-vue";
import { AxiosResponse } from "axios";

export class LazyTable<T = any> {
    // page_index = 1;
    // page_total = 0;
    loading = true;
    data: T[] = [];
    detail: T | undefined = undefined;
    pagination = {
        total: 0,
        current: 1,
        pageSize: 10,
        showQuickJumper: true,
        showSizeChanger: false,
    };
    constructor(
        public page_items = 10,
        paginationOption: PaginationProps = {},
    ) {
        this.pagination.pageSize = page_items;
        Object.assign(this.pagination, paginationOption);
    }
}

export interface ILazyTableService<T = any> {
    getList: (args: any) => Promise<AxiosResponse<Response<T>>>;
    add?: (...args: any) => Promise<any>;
    modify?: (...args: any) => Promise<any>;
    remove?: (...args: any) => Promise<any>;
    enable?: (...args: any) => Promise<any>;
    disable?: (...args: any) => Promise<any>;
}

export abstract class LazyTableService<T = any> implements ILazyTableService {
    abstract getList(args: any): Promise<AxiosResponse<Response<T>>>;
}

export interface BaseAuthApi {
    GETLIST: string;
    REMOVE: string;
    ADD: string;
    MODIFY: string;
}

export interface Pagination {
    current_page: number;
    total_count: number;
    total_pages: number;
    page_items: number;
    last_id: string;
}
export interface Response<T = any> {
    status_code: number;
    msg: string;
    result: {
        data: T;
        page: {} | Pagination;
    };
}
